QTreeWidget Class 您所在的位置:网站首页 qtreewidget clear QTreeWidget Class

QTreeWidget Class

2023-07-22 13:40| 来源: 网络整理| 查看: 265

Member Function Documentation QTreeWidget::QTreeWidget(QWidget *parent = nullptr)

Constructs a tree widget with the given parent.

[slot] void QTreeWidget::clear()

Clears the tree widget by removing all of its items and selections.

Note: Since each item is removed from the tree widget before being deleted, the return value of QTreeWidgetItem::treeWidget() will be invalid when called from an item's destructor.

See also takeTopLevelItem(), topLevelItemCount(), and columnCount().

[slot] void QTreeWidget::collapseItem(const QTreeWidgetItem *item)

Closes the item. This causes the tree containing the item's children to be collapsed.

See also expandItem(), currentItem(), itemAt(), and topLevelItem().

[signal] void QTreeWidget::currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)

This signal is emitted when the current item changes. The current item is specified by current, and this replaces the previous current item.

See also setCurrentItem().

[slot] void QTreeWidget::expandItem(const QTreeWidgetItem *item)

Expands the item. This causes the tree containing the item's children to be expanded.

See also collapseItem(), currentItem(), itemAt(), topLevelItem(), and itemExpanded().

[signal] void QTreeWidget::itemActivated(QTreeWidgetItem *item, int column)

This signal is emitted when the user activates an item by single- or double-clicking (depending on the platform, i.e. on the QStyle::SH_ItemView_ActivateItemOnSingleClick style hint) or pressing a special key (e.g., Enter).

The specified item is the item that was clicked, or nullptr if no item was clicked. The column is the item's column that was clicked, or -1 if no item was clicked.

[signal] void QTreeWidget::itemChanged(QTreeWidgetItem *item, int column)

This signal is emitted when the contents of the column in the specified item changes.

[signal] void QTreeWidget::itemClicked(QTreeWidgetItem *item, int column)

This signal is emitted when the user clicks inside the widget.

The specified item is the item that was clicked. The column is the item's column that was clicked. If no item was clicked, no signal will be emitted.

[signal] void QTreeWidget::itemCollapsed(QTreeWidgetItem *item)

This signal is emitted when the specified item is collapsed so that none of its children are displayed.

Note: This signal will not be emitted if an item changes its state when collapseAll() is invoked.

See also QTreeWidgetItem::isExpanded(), itemExpanded(), and collapseItem().

[signal] void QTreeWidget::itemDoubleClicked(QTreeWidgetItem *item, int column)

This signal is emitted when the user double clicks inside the widget.

The specified item is the item that was clicked, or nullptr if no item was clicked. The column is the item's column that was clicked. If no item was double clicked, no signal will be emitted.

[signal] void QTreeWidget::itemEntered(QTreeWidgetItem *item, int column)

This signal is emitted when the mouse cursor enters an item over the specified column. QTreeWidget mouse tracking needs to be enabled for this feature to work.

[signal] void QTreeWidget::itemExpanded(QTreeWidgetItem *item)

This signal is emitted when the specified item is expanded so that all of its children are displayed.

See also setItemExpanded(), QTreeWidgetItem::isExpanded(), itemCollapsed(), and expandItem().

[signal] void QTreeWidget::itemPressed(QTreeWidgetItem *item, int column)

This signal is emitted when the user presses a mouse button inside the widget.

The specified item is the item that was clicked, or nullptr if no item was clicked. The column is the item's column that was clicked, or -1 if no item was clicked.

[signal] void QTreeWidget::itemSelectionChanged()

This signal is emitted when the selection changes in the tree widget. The current selection can be found with selectedItems().

[slot] void QTreeWidget::scrollToItem(const QTreeWidgetItem *item, QAbstractItemView::ScrollHint hint = EnsureVisible)

Ensures that the item is visible, scrolling the view if necessary using the specified hint.

See also currentItem(), itemAt(), and topLevelItem().

[virtual] QTreeWidget::~QTreeWidget()

Destroys the tree widget and all its items.

void QTreeWidget::addTopLevelItem(QTreeWidgetItem *item)

Appends the item as a top-level item in the widget.

This function was introduced in Qt 4.1.

See also insertTopLevelItem().

void QTreeWidget::addTopLevelItems(const QList &items)

Appends the list of items as a top-level items in the widget.

See also insertTopLevelItems().

void QTreeWidget::closePersistentEditor(QTreeWidgetItem *item, int column = 0)

Closes the persistent editor for the item in the given column.

This function has no effect if no persistent editor is open for this combination of item and column.

See also openPersistentEditor() and isPersistentEditorOpen().

int QTreeWidget::currentColumn() const

Returns the current column in the tree widget.

This function was introduced in Qt 4.1.

See also setCurrentItem() and columnCount().

QTreeWidgetItem *QTreeWidget::currentItem() const

Returns the current item in the tree widget.

See also setCurrentItem() and currentItemChanged().

[override virtual protected] void QTreeWidget::dropEvent(QDropEvent *event)

Reimplements: QAbstractItemView::dropEvent(QDropEvent *event).

[virtual protected] bool QTreeWidget::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action)

Handles the data supplied by a drag and drop operation that ended with the given action in the index in the given parent item.

The default implementation returns true if the drop was successfully handled by decoding the mime data and inserting it into the model; otherwise it returns false.

See also supportedDropActions().

void QTreeWidget::editItem(QTreeWidgetItem *item, int column = 0)

Starts editing the item in the given column if it is editable.

[override virtual protected] bool QTreeWidget::event(QEvent *e)

Reimplements: QAbstractItemView::event(QEvent *event).

QList QTreeWidget::findItems(const QString &text, Qt::MatchFlags flags, int column = 0) const

Returns a list of items that match the given text, using the given flags, in the given column.

QTreeWidgetItem *QTreeWidget::headerItem() const

Returns the item used for the tree widget's header.

See also setHeaderItem().

[protected] QModelIndex QTreeWidget::indexFromItem(const QTreeWidgetItem *item, int column = 0) const

Returns the QModelIndex associated with the given item in the given column.

Note: In Qt versions prior to 5.7, this function took a non-const item.

See also itemFromIndex() and topLevelItem().

int QTreeWidget::indexOfTopLevelItem(QTreeWidgetItem *item) const

Returns the index of the given top-level item, or -1 if the item cannot be found.

See also sortItems() and topLevelItemCount().

void QTreeWidget::insertTopLevelItem(int index, QTreeWidgetItem *item)

Inserts the item at index in the top level in the view.

If the item has already been inserted somewhere else it won't be inserted.

See also addTopLevelItem() and columnCount().

void QTreeWidget::insertTopLevelItems(int index, const QList &items)

Inserts the list of items at index in the top level in the view.

Items that have already been inserted somewhere else won't be inserted.

This function was introduced in Qt 4.1.

See also addTopLevelItems().

QTreeWidgetItem *QTreeWidget::invisibleRootItem() const

Returns the tree widget's invisible root item.

The invisible root item provides access to the tree widget's top-level items through the QTreeWidgetItem API, making it possible to write functions that can treat top-level items and their children in a uniform way; for example, recursive functions.

This function was introduced in Qt 4.2.

bool QTreeWidget::isPersistentEditorOpen(QTreeWidgetItem *item, int column = 0) const

Returns whether a persistent editor is open for item item in column column.

This function was introduced in Qt 5.10.

See also openPersistentEditor() and closePersistentEditor().

QTreeWidgetItem *QTreeWidget::itemAbove(const QTreeWidgetItem *item) const

Returns the item above the given item.

This function was introduced in Qt 4.3.

QTreeWidgetItem *QTreeWidget::itemAt(const QPoint &p) const

Returns a pointer to the item at the coordinates p. The coordinates are relative to the tree widget's viewport().

See also visualItemRect().

QTreeWidgetItem *QTreeWidget::itemAt(int x, int y) const

This is an overloaded function.

Returns a pointer to the item at the coordinates (x, y). The coordinates are relative to the tree widget's viewport().

QTreeWidgetItem *QTreeWidget::itemBelow(const QTreeWidgetItem *item) const

Returns the item visually below the given item.

This function was introduced in Qt 4.3.

[protected] QTreeWidgetItem *QTreeWidget::itemFromIndex(const QModelIndex &index) const

Returns a pointer to the QTreeWidgetItem associated with the given index.

See also indexFromItem().

QWidget *QTreeWidget::itemWidget(QTreeWidgetItem *item, int column) const

Returns the widget displayed in the cell specified by item and the given column.

This function was introduced in Qt 4.1.

See also setItemWidget().

[virtual protected] QMimeData *QTreeWidget::mimeData(const QList items) const

Returns an object that contains a serialized description of the specified items. The format used to describe the items is obtained from the mimeTypes() function.

If the list of items is empty, nullptr is returned rather than a serialized empty list.

[virtual protected] QStringList QTreeWidget::mimeTypes() const

Returns a list of MIME types that can be used to describe a list of treewidget items.

See also mimeData().

void QTreeWidget::openPersistentEditor(QTreeWidgetItem *item, int column = 0)

Opens a persistent editor for the item in the given column.

See also closePersistentEditor() and isPersistentEditorOpen().

void QTreeWidget::removeItemWidget(QTreeWidgetItem *item, int column)

Removes the widget set in the given item in the given column.

This function was introduced in Qt 4.3.

QList QTreeWidget::selectedItems() const

Returns a list of all selected non-hidden items.

See also itemSelectionChanged().

void QTreeWidget::setCurrentItem(QTreeWidgetItem *item)

Sets the current item in the tree widget.

Unless the selection mode is NoSelection, the item is also selected.

See also currentItem() and currentItemChanged().

void QTreeWidget::setCurrentItem(QTreeWidgetItem *item, int column)

Sets the current item in the tree widget and the current column to column.

This function was introduced in Qt 4.1.

See also currentItem().

void QTreeWidget::setCurrentItem(QTreeWidgetItem *item, int column, QItemSelectionModel::SelectionFlags command)

Sets the current item in the tree widget and the current column to column, using the given command.

This function was introduced in Qt 4.4.

See also currentItem().

void QTreeWidget::setHeaderItem(QTreeWidgetItem *item)

Sets the header item for the tree widget. The label for each column in the header is supplied by the corresponding label in the item.

The tree widget takes ownership of the item.

See also headerItem() and setHeaderLabels().

void QTreeWidget::setHeaderLabel(const QString &label)

Same as setHeaderLabels(QStringList(label)).

This function was introduced in Qt 4.2.

void QTreeWidget::setHeaderLabels(const QStringList &labels)

Adds a column in the header for each item in the labels list, and sets the label for each column.

Note that setHeaderLabels() won't remove existing columns.

See also setHeaderItem() and setHeaderLabel().

void QTreeWidget::setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget)

Sets the given widget to be displayed in the cell specified by the given item and column.

The given widget's autoFillBackground property must be set to true, otherwise the widget's background will be transparent, showing both the model data and the tree widget item.

This function should only be used to display static content in the place of a tree widget item. If you want to display custom dynamic content or implement a custom editor widget, use QTreeView and subclass QStyledItemDelegate instead.

This function cannot be called before the item hierarchy has been set up, i.e., the QTreeWidgetItem that will hold widget must have been added to the view before widget is set.

Note: The tree takes ownership of the widget.

This function was introduced in Qt 4.1.

See also itemWidget() and Delegate Classes.

[override virtual] void QTreeWidget::setSelectionModel(QItemSelectionModel *selectionModel)

Reimplements: QTreeView::setSelectionModel(QItemSelectionModel *selectionModel).

int QTreeWidget::sortColumn() const

Returns the column used to sort the contents of the widget.

This function was introduced in Qt 4.1.

See also sortItems().

void QTreeWidget::sortItems(int column, Qt::SortOrder order)

Sorts the items in the widget in the specified order by the values in the given column.

See also sortColumn().

[virtual protected] Qt::DropActions QTreeWidget::supportedDropActions() const

Returns the drop actions supported by this view.

See also Qt::DropActions.

QTreeWidgetItem *QTreeWidget::takeTopLevelItem(int index)

Removes the top-level item at the given index in the tree and returns it, otherwise returns nullptr;

See also insertTopLevelItem(), topLevelItem(), and topLevelItemCount().

QTreeWidgetItem *QTreeWidget::topLevelItem(int index) const

Returns the top level item at the given index, or nullptr if the item does not exist.

See also topLevelItemCount() and insertTopLevelItem().

QRect QTreeWidget::visualItemRect(const QTreeWidgetItem *item) const

Returns the rectangle on the viewport occupied by the item at item.

See also itemAt().



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有